package com.datatest.beans;

import com.datatest.constant.ErrorEnum;
import com.datatest.ex.BusinessException;
import org.springframework.stereotype.Component;

import java.io.FileNotFoundException;
import java.util.List;
import java.util.Map;

public class ResultEntity {

    private Boolean success;
    private Integer code;
    private String seqId;
    private String msg;
    private Map<String,Object> resultSuccess;
    private List<?> resultFail;
    private CreditReportEntity creditReportEntity;


    public ResultEntity(){

    }

    public ResultEntity(Boolean success, Integer code, String seqId, String msg, Map<String, Object> resultSuccess, List<?> resultFail, CreditReportEntity creditReportEntity) {
        this.success = success;
        this.code = code;
        this.seqId = seqId;
        this.msg = msg;
        this.resultSuccess = resultSuccess;
        this.resultFail = resultFail;
        this.creditReportEntity = creditReportEntity;
    }




    /**
     * 自定义异常返回结果NullPointerException
     * @param de
     * @return
     */
    public static ResultEntity fileNotError(NullPointerException de){
        ResultEntity result = new ResultEntity();
        result.setSuccess(false);
        result.setCode(1000);
        result.setMsg(de.toString());

        return result;
    }

    public static ResultEntity defineError(BusinessException e){
        ResultEntity result = new ResultEntity();
        result.setSuccess(false);
        result.setCode(e.getErrorCode());
        result.setMsg(e.getErrorMsg());

        return result;
    }

    /**
     * 其他异常处理方法返回结果
     * @return
     */
    public static ResultEntity otherError(ErrorEnum errorEnum){
        ResultEntity result = new ResultEntity();
        result.setSuccess(false);
        result.setCode(errorEnum.getErrorCode());
        result.setMsg(errorEnum.getEooroMsg());
        return result;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public CreditReportEntity getCreditReportEntity() {
        return creditReportEntity;
    }

    public void setCreditReportEntity(CreditReportEntity creditReportEntity) {
        this.creditReportEntity = creditReportEntity;
    }

    public List<?> getResultFail() {
        return resultFail;
    }

    public void setResultFail(List<?> resultFail) {
        this.resultFail = resultFail;
    }

    public Map<String, Object> getResultSuccess() {
        return resultSuccess;
    }

    public void setResultSuccess(Map<String, Object> resultSuccess) {
        this.resultSuccess = resultSuccess;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getSeqId() {
        return seqId;
    }

    public void setSeqId(String seqId) {
        this.seqId = seqId;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
